package net.beeapm.demo.skywalking;

import org.apache.skywalking.apm.toolkit.trace.TraceCrossThread;

import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;

//一个 能够跨线程  传递 trace 标记的 异步任务
@TraceCrossThread
public class TraceCrossCallable implements Callable<java.lang.String> {
    private final CountDownLatch latch;

    public TraceCrossCallable(CountDownLatch latch) {
        this.latch = latch;
    }

    // skywalking aop 里边的 切点对这个方法，进行了 匹配
    // call、run、get 增强
    @Override
//    public String call$original$2kIeyHbh$accessor$M4nmpd6W() throws Exception {
    public String call() throws Exception {
        Thread.sleep(100);
        latch.countDown();
        return  "unknown";
    }
}